package com.teacher.game.framework.util;

import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import com.teacher.game.state.State;
import com.teacher.ellio.GameMainActivity;

public class InputHandler implements View.OnTouchListener{

    private State currentState;

    public  void setCurrentState(State currentState){
        this.currentState = currentState;
    }

    @Override
    public boolean onTouch(View view, MotionEvent e) {
        //Log.d("MenuState", "点击了屏幕坐标（"+e.getX()+","+e.getY()+"）");
        int scaleX = (int) (e.getX() / view.getWidth() * GameMainActivity.GAME_WIDTH);
        int scaleY = (int) (e.getY() / view.getHeight() * GameMainActivity.GAME_HEIGHT);

        return currentState.onTouch(e,scaleX,scaleY);
    }
}
